/*
 * @Author: qinruiguang
 * @LastEditors: qinruiguang
 * @Date: 2021-08-10 13:28:27
 * @LastEditTime: 2021-09-03 16:03:31
 */
import { app, ipcMain, BrowserWindow, desktopCapturer } from 'electron'
export let win = (id, url) => {
    if (winObj.get(id)) {
        winObj.get(id).show()
        winObj.get(id).focus()
        return
    }
    let win = new BrowserWindow({
        useContentSize: true, //网页字体  
        frame: false, //无边框
        height: 600,
        width: 900,
        minWidth: vb.width ? vb.width : 0,
        minHeight: vb.height ? vb.height : 0,
        movable: true, //是否可挪动
        resizable: true, //窗口可否改不大小
        hasShadow: true, //窗口阴影
        // darkTheme:true, //窗口使用 dark 主题
        //skipTaskbar: false, //windows任务栏窗口去除（true）
        // transparent: true, //透明窗体
        // alwaysOnTop: true, //窗口置顶
        autoHideMenuBar: true, //去除菜单 
        show: false,//是否显示
        fullscreen: false, //全屏
        fullscreenable: true, //是否可以全屏
        webPreferences: {
            webSecurity: true,
            enableRemoteModule: true,
            nodeIntegrationInWorker: true,
            nodeIntegration: true, //是否完整支持node
            nativeWindowOpen: true,
            contextIsolation: false, //require is not defined 处理  
            //preload: path.join(__dirname, 'preload.js'),
            // devTools: true //控制开发模式
        }, ...vb
    })
    //加载url
    // console.log(url)
    if (url.indexOf("file://") >= 0) {
        win.loadFile(url)
    } else {
        win.loadURL(url)
    }
    win.loadURL(url)
    win.show()
    if(vb.webPreferences&&vb.webPreferences.devTools) win.webContents.openDevTools()
    winObj.set(id, win)
}